import { execSync } from 'child_process';

const runCommand = (command) => {
  console.log(`\n🚀 执行: ${command}`);
  try {
    execSync(command, { stdio: 'inherit' });
  } catch (error) {
    console.error(`❌ 命令执行失败: ${command}\n错误详情: ${error.message}`);
    process.exit(1);
  }
};

console.log('📦 开始构建和打包流程...\n');

// 定义任务列表
const tasks = [
  'pnpm run build',
  'docker build -t agriculture .',
  'docker tag agriculture asl1204/agriculture:latest',
  'docker save -o agriculture.tar asl1204/agriculture:latest'
];

// 按顺序执行任务
tasks.forEach(runCommand);

console.log('\n✅ 构建和打包完成！');
